-
-
Notifications
You must be signed in to change notification settings - Fork 434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
openapi3: implement circular reference backtracking #970
openapi3: implement circular reference backtracking #970
Conversation
204c38a
to
1871e49
Compare
@fenollp I updated the PR description and its contents :) This should solve circular references resolution for good. Let me know if you have any questions or concerns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi & thanks for taking the time to look into this!
Mostly LGTM, just: I see you're not using the visitref utils you're introducing in these two places and it feels like this was fogotten?
func (loader *Loader) resolveLinkRef(doc *T, component *LinkRef, documentPath *url.URL) (err error)
func (loader *Loader) resolvePathItemRef(doc *T, pathItem *PathItem, documentPath *url.URL) (err error)
Could you comment on or fix that please?
Thanks for a quick review! I indeed missed a couple of functions. It's ready for re-review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
* feat(loader): implement reference back-tracking * update docs * address review comments * update docs and readme * fix inconsistency * adjust readme
This PR adds a test scenario that leads to failure of resolving recursive references.
After troubleshooting for a while, I realized that current reference tracking algorithm in not perfect and will always have some edge cases, so I decided to try fixing that for good.
During reference resolution, we keep track of all previous references, and if we find out that the reference is already being resolved, we register a backtracking callback that will assign a pointer to the resolved schema once it's done.
This guarantees that schema will always be resolved regardless of the depth.